package repository;

import com.sun.org.apache.xpath.internal.operations.Mod;
import dbConnect.dbConnecter;
import Dto.UserTbEntity;

import javax.jws.WebParam;
import java.sql.ResultSet;

public class UserRepository {
    private dbConnecter conn;


    public  UserRepository()
    {
    }



    public boolean getUserInfoByAccount(String account, UserTbEntity Model)
    {
        try {
            conn = new dbConnecter();
            conn.getConnection();

            String sql = "select * from User_tb where userAccount=" + dbConnecter.toSql(account);

            ResultSet re = conn.querySql(sql);

            while (re.next())
            {
                Model.setUserId(re.getString(6));
                Model.setUserAccount(account);
                Model.setUserName(re.getString(1));
                Model.setUserType(re.getString(4));
                Model.setUserStatus(re.getString(5));
                Model.setAdmin(re.getInt(7));
                return  true;
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
            return false;
        }
        finally {
            conn.close();
        }
        return false;
    }
}
